<?
layout("/inc/win_layout.html",{title:sysTitle}){}
    ?>

<div class="page-content">
	<div class="row mbl">
			<div class="col-lg-12">
				<div class="input-group input-group-sm mbs">
					<table style="margin-top: 5px;">
						<tr >
							<td align="right" style="width: 100px;">用户名&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 80%;" id="username" name="username" /></td>
							<td align="right" style="width: 100px;">机构名称&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 80%;" id="realname" name="realname" /></td>
							<td align="right" style="width: 100px;">用户类型&nbsp;&nbsp;</td>
							<td>
								<select id="type" class="form-control" tyle="width: 80%;">
									<option value="">请选择</option>
									<option value="1">机构</option>
									<option value="0">个人</option>
								</select>
							</td>
							<td align="right" style="width: 100px;">
								<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="demo(1)">查询</button>
								&nbsp;&nbsp;
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
		<table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
			<thead>
				<tr>
					<th>请勾选</th>
					<th>序号</th>
					<th>用户名</th>
					<th>机构名称</th>
					<th>用户类型</th>
					<th>创建时间</th>
					<th>状态</th>
				</tr>
			</thead>
			<tbody id="findUser">
			
			</tbody>
		</table>
		<div id="page2" style="text-align: center; margin-top: 20px;"></div>
	</div>
<script type="text/javascript">
	function getQueryString(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
	} 
var winName=getQueryString("winName");
	$(function() {

		demo(1);
	});
	function demo(curr){
		$.ajax({
			type : "post",
			url : "listfindAll.do",
			dataType : "json",
			data :{
				page : curr || 1,
				username : $("#username").val(),
				realname : $("#realname").val(),
				type : $("#type").val(),
			},
			beforeSend : function(XMLHttpRequest) {
			},
			success : function(res){
			    //alert(JSON.stringify(res));
				var str = "";
				$("#findUser").html("");
				if (res.listsize > 0) {
								$("#dataNull").html("");
							} else {
								$("#dataNull").html(
									"<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
							}
							for ( var i = 0; i < res.listsize; i++) {
							//if(res.result[i].type == 1){
								var statusname;
								if (res.result[i].status == 0) {
									statusname = "启用";
								} else {
									statusname = "禁用";
								}
								var type;
								if (res.result[i].type == 0) {
									type = "个人用户";
								}
								if (res.result[i].type == 1) {
									type = "机构用户";
								}
								if (res.result[i].type == 2) {
									type = "机构下的个人用户";
								}
								str += "<tr><td><input type='checkbox' id='organizationId' name='checkall' nameZh='"+res.result[i].username+"' value='"+res.result[i].id+"'/></td><td>"
										+ (i + 1)
										+ "</td><td> <label for="+res.result[i].id+">"
										+ res.result[i].username
										+ "</label></td><td><label >"
										+ res.result[i].realname
										+ "</label></td><td><label >"
										+ type
										+ "</label></td><td><label >"
										+ res.result[i].createTime
										+ "</label></td><td><label >"
										+ statusname
										+ "</label></td>"
										+ "</tr>";
								//}
							}
					$("#findUser").append(str);
					laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : res.pageSize, //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: curr || 1,
					last: res.pageSize,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo(obj.curr);
							 curr = obj.curr;
						}
					}
				});
			}
		});
	
	}

	function save(){
	var organizationUserid = '';
	var nameZh = '';
	$("input[name='checkall']:checked").each(function(){
			organizationUserid = $(this).val();
			nameZh = $(this).attr("nameZh");
	});
	 var index = parent.layer.getFrameIndex(window.name); 
	    window.parent.window[winName].$("#organizationUserid").val(organizationUserid);
	    window.parent.window[winName].queryJg(organizationUserid);
	    window.parent.window[winName].$("#organizationUserZh").val(nameZh);
	    parent.layer.close(index); 
	}
		$("tr").live("click", function () {
		     if ($(this).hasClass("bgRed")) {
		         $(this).removeClass("bgRed").find(":checkbox").attr("checked", false);
		     } else {
		                $(this).addClass("bgRed").find(":checkbox").attr("checked", true);
		            }
		 });
</script>
